package com.open.capacity.reptile.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.open.capacity.commons.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.open.capacity.commons.CodeEnum;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections4.MapUtils;

import com.open.capacity.reptile.entity.GdszczMaEleDeppro;
import com.open.capacity.reptile.dao.GdszczMaEleDepproDao;
import com.open.capacity.reptile.service.GdszczMaEleDepproService;


@Service
public class GdszczMaEleDepproServiceImpl  implements GdszczMaEleDepproService {

    @Autowired
    private GdszczMaEleDepproDao gdszczMaEleDepproDao;

    /**
     * 添加
     * @param gdszczMaEleDeppro
     */
    public int save(GdszczMaEleDeppro gdszczMaEleDeppro){
    	  return gdszczMaEleDepproDao.save(gdszczMaEleDeppro);
    }



    /**
     * 删除
     * @param id
     */
    public int delete(String id){
        return gdszczMaEleDepproDao.delete(id);
    }

    /**
     * 查询记录
     * @param id
     * @return
     */
    public GdszczMaEleDeppro findById(String id){
        return gdszczMaEleDepproDao.findById(id);
    }


    @Override
    public int exists(String id) {
        return gdszczMaEleDepproDao.exists(id);
    }

    /**
     * 分页
     * @param params
     * @return
     */
    public PageResult<GdszczMaEleDeppro> pageAll(Map<String, Object> params){
        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
        if (MapUtils.getInteger(params, "page")!=null && MapUtils.getInteger(params, "limit")!=null)
            PageHelper.startPage(MapUtils.getInteger(params, "page"),MapUtils.getInteger(params, "limit"),true);

        List<GdszczMaEleDeppro> list  =  gdszczMaEleDepproDao.findAll(params);
        PageInfo<GdszczMaEleDeppro> pageInfo = new PageInfo(list);

        return PageResult.<GdszczMaEleDeppro>builder().data(pageInfo.getList()).resp_code(CodeEnum.SUCCESS.getCode()).count(pageInfo.getTotal()).build();
    }

    /**
    * 列表
    * @param params
    * @return
    */
    public List<GdszczMaEleDeppro> findAll(Map<String, Object> params){
        return  gdszczMaEleDepproDao.findAll(params);
    }

}
